from loggerserver import ZmqPublisher
from loggerserver import LoggerServer
import zmq
import time

class LoggerServerWrapper(object):
    def __init__(self,config_file,publisher):
        #self.endpoint_ = "tcp://*:" + str(port)
        self.logger_pub_ = publisher
        self.logger_server_ =  LoggerServer(self.logger_pub_)

        if not self.logger_server_.load_config(config_file=config_file):
            print "Fail to initialize loggers"
            exit()
        time.sleep(0.2)



    def start(self):
        try:
            self.logger_server_.start()
            while True:
                time.sleep(1)
        finally:
            self.logger_server_.receiving = False
